package com.hyperboost.backend.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hyperboost.common.annotation.Log;
import com.hyperboost.common.core.controller.BaseController;
import com.hyperboost.common.core.domain.AjaxResult;
import com.hyperboost.common.enums.BusinessType;
import com.hyperboost.backend.domain.ShareComment;
import com.hyperboost.backend.service.IShareCommentService;
import com.hyperboost.common.utils.poi.ExcelUtil;
import com.hyperboost.common.core.page.TableDataInfo;

/**
 * 分享评论Controller
 * 
 * @author LXY
 * @date 2025-04-19
 */
@RestController
@RequestMapping("/backend/shareComment")
public class ShareCommentController extends BaseController
{
    @Autowired
    private IShareCommentService shareCommentService;

    /**
     * 查询分享评论列表
     */
    @PreAuthorize("@ss.hasPermi('backend:shareComment:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShareComment shareComment)
    {
        startPage();
        List<ShareComment> list = shareCommentService.selectShareCommentList(shareComment);
        return getDataTable(list);
    }

    /**
     * 导出分享评论列表
     */
    @PreAuthorize("@ss.hasPermi('backend:shareComment:export')")
    @Log(title = "分享评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShareComment shareComment)
    {
        List<ShareComment> list = shareCommentService.selectShareCommentList(shareComment);
        ExcelUtil<ShareComment> util = new ExcelUtil<ShareComment>(ShareComment.class);
        util.exportExcel(response, list, "分享评论数据");
    }

    /**
     * 获取分享评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('backend:shareComment:query')")
    @GetMapping(value = "/{commentId}")
    public AjaxResult getInfo(@PathVariable("commentId") Long commentId)
    {
        return success(shareCommentService.selectShareCommentByCommentId(commentId));
    }

    /**
     * 新增分享评论
     */
    @PreAuthorize("@ss.hasPermi('backend:shareComment:add')")
    @Log(title = "分享评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShareComment shareComment)
    {
        return toAjax(shareCommentService.insertShareComment(shareComment));
    }

    /**
     * 修改分享评论
     */
    @PreAuthorize("@ss.hasPermi('backend:shareComment:edit')")
    @Log(title = "分享评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShareComment shareComment)
    {
        return toAjax(shareCommentService.updateShareComment(shareComment));
    }

    /**
     * 删除分享评论
     */
    @PreAuthorize("@ss.hasPermi('backend:shareComment:remove')")
    @Log(title = "分享评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commentIds}")
    public AjaxResult remove(@PathVariable Long[] commentIds)
    {
        return toAjax(shareCommentService.deleteShareCommentByCommentIds(commentIds));
    }
}
